package com.inco.cloud.common.config;

import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.stereotype.Component;

@Component
public class IncoPasswordEncoder implements PasswordEncoder {


    public IncoPasswordEncoder(){
        System.out.println("----------IncoPasswordEncoder--------------");
    }

    @Override
    public String encode(CharSequence rawPassword) {
        System.out.println("调用==encode=="+rawPassword.toString());
        return rawPassword.toString();
    }

    /**
     *
     * @param rawPassword 从前端传递过来的密码
     * @param encodedPassword 从数据库中取到的密码
     * @return
     */
    @Override
    public boolean matches(CharSequence rawPassword, String encodedPassword) {
        System.out.println("rawPassword="+rawPassword);
        System.out.println("encodedPassword="+encodedPassword);
        boolean re = rawPassword.toString().equals(encodedPassword);
        System.out.println("re="+re);
        return re;
    }
}
